import os


def prepare(video_dir,):
    '''
    从指定文件夹中读出所有 视频的文件名
    :param selected: 被选择 要处理的 视频文件编号
    :return:
    '''
    video_names = []
    for home, dirs, files in os.walk(video_dir):
        for video_name in files:
            video_path = os.path.join(home, video_name)

            filename = os.path.splitext(video_name)

            if not filename[-1] in [".mp4", ".avi"]:
                continue

            video_names.append(video_path)

    return video_names

def create_video_list(video_dir, video_filename):
    video_names = prepare(video_dir)
    with  open(video_filename,'w',encoding="utf-8") as f:
        for item in video_names:
            f.writelines(item)
            f.write("\n")

if __name__ == '__main__':
    video_dir = r"E:\武科大视频\分割后"
    video_filename = r"74_videos.txt"
    create_video_list(video_dir, video_filename)
